﻿using Common.Package;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Common.Handle
{
    /// <summary>
    /// 登录处理
    /// </summary>
    /// 
    [PacketType(RecvPacketOpcode.帐号登录)]
    public class MapleLoginHandle : MaplePacketHandler
    {
        public void HandlePacket(MapleClient client, Buffer.MaplePacketRead slea)
        {
            string _Name = slea.ReadMapleAsciiString();
            string _Pass = slea.ReadMapleAsciiString();

            switch (client.Login(_Name, _Pass))
            {
                case -1://未注册帐号
                    {
                        client.Send(MapleLoginPacket.GetLoginError(5));
                        break;
                    }
                    break;
                case 0://登陆成功!!
                    {
                        client.Send(MapleLoginPacket.GetAuthSuccessRequest(client));
                        client.Send(MapleLoginPacket.getServerList(3,0));
                        client.Send(MapleLoginPacket.getServerList(3,1));
                        client.Send(MapleLoginPacket.getEndOfServerList());
                        break;
                    }
                case 1://密码错误
                    {
                        client.Send(MapleLoginPacket.GetLoginError(4));
                        break;
                    }
                case 2://已在线
                    {
                        client.Send(MapleLoginPacket.GetLoginError(7));
                        break;
                    }
            }
        }
    }
}
